class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        if not strs:
            return ""
        strs.sort()
        start = strs[0]
        end = strs[-1]
        for i, ch in enumerate(start):
            if start[i] == end[i]:
                continue
            else:
                return start[:i]
        return start

class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        res = ""
        for item in list(zip(*strs)):
            if len(set(item)) > 1:
                break
            else:
                res += ''.join(set(item))
        return res